package com.jiantong.lawEnforcing.impl.dao;

import com.google.common.collect.Maps;
import com.jiantong.lawEnforcing.model.BreedLegalGround;
import io.terminus.common.model.Paging;
import io.terminus.common.mysql.dao.MyBatisDao;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * 案件处罚对照表
 * Created by mz03 on 2017/9/27.
 */
@Repository
public class BreedLegalGroundDao extends MyBatisDao<BreedLegalGround>{


    public Paging<BreedLegalGround> pagingList(Integer offset, Integer limit, Map<String, Object> criteria) {
        if(criteria == null) {
            criteria = Maps.newHashMap();
        }

        Long total = (Long)this.sqlSession.selectOne(this.sqlId("countList"), criteria);
        if(total.longValue() <= 0L) {
            return new Paging(Long.valueOf(0L), Collections.emptyList());
        } else {
            ((Map)criteria).put("offset", offset);
            ((Map)criteria).put("limit", limit);
            List datas = this.sqlSession.selectList(this.sqlId("pagingList"), criteria);
            return new Paging(total, datas);
        }
    }


    public List<BreedLegalGround> findByType(){
        return this.sqlSession.selectList(this.sqlId("findByType"));
    }

}
